package com.example.kotlinstudy

import android.os.Bundle
import android.view.View
import android.widget.ImageView
import android.widget.Toast
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.bumptech.glide.Glide
import com.example.myapplication.R


class ImageActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        // 对标鸿蒙中的 $r
        setContentView(R.layout.activity_image)
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }

        val img = findViewById<ImageView>(R.id.imageView2)
        Glide.with(this)
            .load("https://img1.baidu.com/it/u=3968087686,3071068318&fm=253&app=138&f=JPEG?w=800&h=1148")
            .into(img)
    }

    // 图片的点击事件
    fun clickImage(view: View) {
        Toast.makeText(this, "点击了图片", Toast.LENGTH_SHORT).show()
    }
}